|
bool | addAbstractChildOverride (NodeSharedPtr child) override |
| Node::addAbstractChildOverride() implementation. More...
|
|
void | addChild (Node2DSharedPtr child) |
| Adds a child node. More...
|
|
void | arrange () |
| Arranges a 2D node. More...
|
|
ChildConstIterator | beginChildren () const |
|
bool | compositionRequiresAlpha () const |
| Returns whether composition requires alpha. More...
|
|
bool | compositionRequiresDepth () const |
| Returns whether composition requires depth. More...
|
|
bool | compositionRequiresStencil () const |
| Returns whether composition requires stencil. More...
|
|
optional< Vector2 > | containsGlobal (Vector2 point) const |
| Checks whether a node area contains a point defined in screen space. If it does, writes the node-space coordinates into the outgoing point. More...
|
|
bool | containsLocal (Vector2 point) const |
| Returns whether a node area contains a point defined in the local space of the node. More...
|
|
ChildConstIterator | endChildren () const |
|
NodeSharedPtr | findAbstractChildOverride (string_view name) override |
| Node::findAbstractChildOverride() implementation. More...
|
|
size_t | getAbstractChildCountOverride () override |
| Node::getAbstractChildCountOverride() implementation. More...
|
|
size_t | getAbstractChildIndexOverride (const Node &node) override |
|
NodeSharedPtr | getAbstractChildOverride (size_t index) override |
| Node::getAbstractChildOverride() implementation. More...
|
|
Vector2 | getActualSize () const |
| Gets the actual size of a node. More...
|
|
Vector2 | getAllocatedSize () const |
| Gets the allocated size of a node. More...
|
|
Matrix3x3 | getArrangeTransform () const |
| Gets the arrange transform. More...
|
|
BrushSharedPtr | getBackgroundBrush () const |
| Gets value of BackgroundBrushProperty. More...
|
|
BrushRenderer * | getBackgroundBrushRenderer () const |
| Get background brush renderer. More...
|
|
QuadDescription | getBackgroundQuad () const |
| Gets the background quad description. More...
|
|
Node2DSharedPtr | getChild (size_t index) const |
| Returns a child from given index from object node. More...
|
|
Matrix3x3 | getChildCompositionSpaceTransform () const |
| Gets the transform used for composition children of the 2D node. More...
|
|
size_t | getChildCount () const |
| Gets the number of children of the node. More...
|
|
size_t | getChildIndex (const Node &child) const |
| Returns the index of a child in an object node. More...
|
|
ClippingArea | getClippingArea () const |
| Gets the clipping area. More...
|
|
BrushSharedPtr | getCompositionBrush () const |
| Gets value of CompositionBrushProperty. More...
|
|
BrushRenderer * | getCompositionBrushRenderer () const |
| Access cache result brush renderer. More...
|
|
CompositionManager * | getCompositionManager () const |
| Access composition manager. More...
|
|
TextureSharedPtr | getCompositionTarget () const |
| Gets the composition target used for compositing the node. More...
|
|
NodeCompositor2D * | getCompositor () const |
| Accesses the compositor component. More...
|
|
Vector2 | getContentDesiredSize () const |
| Gets the size desired by content. More...
|
|
Vector2 | getDesiredSize () const |
| Gets the desired size of a node. More...
|
|
NodeEffect2DSharedPtr | getEffect () const |
| Gets the value of EffectProperty. More...
|
|
NodeEffectPrefab2DSharedPtr | getEffectPrefab () const |
| Gets the value of EffectPrefabProperty. More...
|
|
NodeEffectRenderer2D * | getEffectRenderer () const |
| Gets the effect renderer. More...
|
|
BrushSharedPtr | getForegroundBrush () const |
| Gets value of ForegroundBrushProperty. More...
|
|
BrushRenderer * | getForegroundBrushRenderer () const |
| Get foreground brush renderer. More...
|
|
float | getLayoutOpacity () const |
| Gets the opacity after propagation from layouting hierarchy. More...
|
|
SRTValue2D | getLayoutTransformation () const |
| Gets the value of the LayoutTransformationProperty. More...
|
|
TextureSharedPtr | getManagedCompositionTarget () const |
| Gets the managed composition target of a node. More...
|
|
Matrix3x3 | getParentSpaceTransform () const |
| Gets the parent space transform of the 2D node. More...
|
|
Matrix3x3 | getPartialArrangeTransform () const |
| Gets the partial arrange transform. More...
|
|
NodeEffect2D * | getRenderableEffect () const |
| Gets a pointer to the current effect if effect rendering is required. More...
|
|
Matrix3x3 | getRenderQuadTransform () const |
| Gets transformation used to render the 2D node. More...
|
|
TextureSharedPtr | getRenderTarget () const |
| Gets value of RenderTargetProperty. More...
|
|
SRTValue2D | getRenderTransformation () const |
| Gets the value of RenderTransformationProperty. More...
|
|
RenderType | getRenderType () const |
| Get render type. More...
|
|
Vector2 | getSecondPassDesiredSize () const |
| Gets the second pass desired size. More...
|
|
Vector2 | getUserDesiredSize () const |
| Gets the size desired by user. More...
|
|
NodeVisual2D * | getVisual () const |
| Access visual component. More...
|
|
Matrix3x3 | getWorldTransform () const |
| Gets the world transformation matrix. More...
|
|
optional< Vector2 > | globalToLocal (Vector2 point) const |
|
bool | hasCenterClipArea () const |
| Returns whether a 2D node has the center clip area (the area of foreground content). More...
|
|
bool | hasChild (const Node &child) const |
| Returns whether the given node is a child of this node. More...
|
|
bool | hasCompositionTarget () const |
| Indicates whether the node has a composition target. More...
|
|
bool | hasEffect () const |
| Whether an active effect is applied to this node. More...
|
|
bool | hasManagedCompositionTarget () const |
| Returns whether the node has a managed composition target. More...
|
|
bool | hasOutsideClipArea () const |
| Returns whether a 2D node has outside clipping area. More...
|
|
bool | hasTranslucentForeground () const |
| Returns whether the foreground of a 2D node has translucency. More...
|
|
NodeSharedPtr | hitTest (Vector2 point) |
| Performs a hit test to a 2D node and all its child nodes. More...
|
|
NodeSharedPtr | hitTest (Vector2 point, const Metaclass *type) |
| Performs a hit test to a 2D node and all its child nodes. More...
|
|
template<typename T > |
shared_ptr< T > | hitTest (Vector2 point) |
| Wrapper for hitTest(Vector2), casts the return value. More...
|
|
template<typename T > |
shared_ptr< T > | hitTest (Vector2 point, const Metaclass *type) |
| Wrapper for hitTest(Vector2, const Metaclass), casts the return value. More...
|
|
virtual tuple< NodeSharedPtr, Ray, float > | hitTestContent (Vector2 point) |
| Default implementation of Node2D content hit test. More...
|
|
NodeSharedPtr | hitTestIterate (Vector2 point, HitTestVisitor visitor, void *userData) |
| Hit tests nodes recursively from this node downwards and calls visitor function on the hit nodes. More...
|
|
void | insertChild (size_t index, Node2DSharedPtr child) |
| Adds a child node for object node to given index. More...
|
|
bool | isCacheValid () const |
| Returns whether the children cache is valid. More...
|
|
bool | isClearColorAllowed () const |
| Returns whether this Node2D is allowed and should clear the color buffer of its own composition target. More...
|
|
bool | isCompletelyClipped () const |
| Returns whether a node is completely clipped and needs not be rendered. More...
|
|
bool | isCompletelyTransparent () const |
| Returns whether a node is completely transparent. More...
|
|
bool | isCompositionPotentiallyRequired () const |
| Tell if node itself is going to get rendered into a composition target. More...
|
|
bool | isPerspectiveTransformActive () const |
| Returns whether a node is being perspective transformed. More...
|
|
bool | isRenderChildrenAllowed () const |
| Returns whether rendering children is allowed. More...
|
|
bool | isRenderSelfAllowed () const |
| Returns whether render self is allowed. More...
|
|
bool | isSelfInCompositionTarget () const |
| Returns whether the node is going to get rendered into a composition target. More...
|
|
bool | isVisibleForHitTesting () const |
| Returns whether a 2D node is visible for hit testing. More...
|
|
void | layout (optional< Matrix3x3 > rootTransform) |
| Does a layout pass starting from this node and iterating recursively all of its children. More...
|
|
void | layout () |
| Does layout pass with no root transformation (identity). More...
|
|
bool | measure (const Vector2 *availableSize, bool handleStretch) |
| Measures one node. More...
|
|
virtual bool | measureRecursive () |
| Performs measure recursively. More...
|
|
bool | moveAbstractChildToPositionOverride (NodeSharedPtr child, size_t index) override |
| Node::moveAbstractChildToPosition() implementation. More...
|
|
void | moveChildToPosition (Node2DSharedPtr child, size_t index) |
| Moves a child node to a given position in the list of child nodes. More...
|
|
void | moveToBack () |
| Repositions the node to the beginning of its parent's children, so that it is drawn first. More...
|
|
void | moveToFront () |
| Repositions the node to the end of its parent's children, so that it is drawn last. More...
|
|
ChildConstReverseIterator | rbeginChildren () const |
|
bool | removeAbstractChildOverride (Node &child) override |
| Node::removeAbstractChildOverride() implementation. More...
|
|
void | removeAllChildren () |
| Removes all child nodes. More...
|
|
void | removeChild (const Node &child) |
| Removes child node. More...
|
|
void | removeChild (size_t index) |
| Removes child node at specified index. More...
|
|
ChildConstReverseIterator | rendChildren () const |
|
void | render (Renderer3D &renderer, CompositionStack &compositionStack, const optional< Matrix3x3 > &baseTransform) |
| Renders a node and its descendant nodes. More...
|
|
void | render (Renderer3D &renderer, CompositionStack &compositionStack) |
| Render a node and its descendant nodes. More...
|
|
bool | requiresBackgroundBrushRendering () const |
| Returns whether background brush rendering is required. More...
|
|
bool | requiresForegroundBrushRendering () const |
| Returns whether foreground brush rendering is required. More...
|
|
bool | requiresLocalTransformationScope () const |
| Indicates whether local transformation scope is required. More...
|
|
bool | requiresTilingUpdate () const |
| Returns whether node geometry requires an update for the tiling. More...
|
|
void | resetCache () |
| Resets cached content for complete content of a node, including the node and its children. More...
|
|
void | setActualSize (Vector2 actualSize) |
| Sets the actual size of a node. More...
|
|
void | setActualSize (float sizeX, float sizeY) |
| Sets the actual size of a node. More...
|
|
void | setAllocatedSize (Vector2 allocatedSize) |
| Sets the allocated size of a node. More...
|
|
void | setArrangeTransform (Matrix3x3 transform) |
| Sets the arrange transform. More...
|
|
void | setAutoHeight () |
| Sets a node to determine its height automatically. More...
|
|
void | setAutoSize () |
| Sets a node to determine its width and height automatically. More...
|
|
void | setAutoWidth () |
| Sets a node to determine its width automatically. More...
|
|
void | setBackgroundBrush (BrushSharedPtr value) |
| Sets value of BackgroundBrushProperty. More...
|
|
void | setClearColorAllowed (bool enabled) |
| Sets clear color allowed. More...
|
|
void | setCompositionBrush (BrushSharedPtr value) |
| Sets value of CompositionBrushProperty. More...
|
|
void | setCompositionRequested (bool enabled) |
| Turns the composition request on or off. More...
|
|
void | setCompositionRequiresAlpha (bool enabled) |
| Turns the composition alpha requirement on or off. More...
|
|
void | setCompositionRequiresDepth (bool enabled) |
| Turns the composition depth requirement on or off. More...
|
|
void | setCompositionRequiresStencil (bool enabled) |
| Turns the composition stencil requirement on or off. More...
|
|
void | setDesiredSize (Vector2 desiredSize) |
| Sets the desired size of a node. More...
|
|
void | setEffectPrefab (NodeEffectPrefab2DSharedPtr value) |
| Sets the value of EffectPrefabProperty. More...
|
|
void | setForegroundBrush (BrushSharedPtr value) |
| Sets value of ForegroundBrushProperty. More...
|
|
void | setForegroundIsTranslucent (bool enabled) |
| Sets the status of the foreground translucency. More...
|
|
KZ_DEPRECATED void | setLayoutSize (float width, float height) |
| Sets size properties of the node. More...
|
|
void | setLayoutTransformation (SRTValue2D value) |
| Sets the value of the LayoutTransformationProperty. More...
|
|
void | setPotentialCompositionBitViewport (bool enabled) |
| Turns the potential composition flag for the viewport on or off. More...
|
|
void | setRenderTarget (TextureSharedPtr texture) |
| Sets value of RenderTargetProperty. More...
|
|
void | setRenderTransformation (SRTValue2D value) |
| Sets the value of RenderTransformationProperty. More...
|
|
void | setRequiresLocalTransformationScope (bool enabled) |
| Sets the local transformation scope requirement. More...
|
|
void | setRequiresTilingUpdate (bool enabled) |
| Sets the tiling update requirement. More...
|
|
void | setSize (float width, float height) |
| Sets the size of a node. More...
|
|
void | setSize (Vector2 size) |
| Sets the size of a node. More...
|
|
void | transform () |
| Transforms a 2D node. More...
|
|
VisitorResult | visitAbstractChildOverride (const Visitor &visitor, VisitorOrder order) override |
| Node::visitAabstractChild implementation. More...
|
|
| ~Node2D () override |
|
ResourceSharedPtr | acquireResource (const ResourceID &id) const |
| Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary. More...
|
|
template<typename T > |
shared_ptr< T > | acquireResource (const ResourceID &id) const |
| Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary, and casts the resource to given type. More...
|
|
ResourceManager::AcquireTaskSharedPtr | acquireResourceAsync (const ResourceID &key, ResourceManager::AsyncAcquireFinishedCallback func) const |
| Posts an asynchronous task to acquire a resource. More...
|
|
ResourceDictionarySharedPtr | acquireResourceDictionary () |
| Gets a resource dictionary of a node. More...
|
|
void | addAnonymousResource (ResourceSharedPtr resource) |
| Adds alias resource to an object node. More...
|
|
void | addInputManipulator (InputManipulatorBaseSharedPtr inputManipulator) |
| Transfers the ownership and attaches an input manipulator to an object node. More...
|
|
template<typename TMessageType , typename TClass , typename TClassMethod > |
MessageSubscriptionToken | addMessageFilter (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method) |
| Adds a message filter where the filter is a method that is invoked on an object. More...
|
|
template<typename TMessageType > |
MessageSubscriptionToken | addMessageFilter (const TMessageType &messageType, typename TMessageType::FunctionType function) |
| Adds a message filter where the filter is a function. More...
|
|
template<typename TMessageType , typename TClass , typename TClassMethod > |
MessageSubscriptionToken | addMessageHandler (TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method) |
| Adds a message handler where the handler is a method that is invoked on an object. More...
|
|
template<typename TMessageType > |
MessageSubscriptionToken | addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function) |
| Adds a message handler where the handler is a function. More...
|
|
template<typename TMessageType > |
MessageSubscriptionToken | addMessageHandler (const TMessageType &messageType, typename TMessageType::FunctionType function, Node *messageSourceFilter) |
| Adds a message handler where the handler is a function and you explicitly define the accepted source. More...
|
|
void | addNodeComponent (NodeComponentSharedPtr nodeComponent) |
| Transfers the ownership of a node component to an object node. More...
|
|
void | addNodeComponentWithOwner (NodeComponentSharedPtr nodeComponent, const void *owner) |
| Transfers the ownership of a node component to an object node and sets the owner of the node component. More...
|
|
void | addNodeReference (AbstractPropertyType propertyType, AbstractNodeReference *reference) |
|
void | addResource (const ResourceID &resourceId, string_view resourceUrl) |
| Adds a resource manager resource to an object node. If resourceID already exists in object, removes the existing entry. If resourceURL is NULL, error is thrown. */. More...
|
|
void | addResourceDictionary (ResourceDictionarySharedPtr resourceDictionary) |
| Adds a nested resource dictionary to the resource dictionary of a node. More...
|
|
void | addResourceReference (AbstractPropertyType propertyType, AbstractResourceReference *reference) |
| This is a helper for automatic resource tracking in ResourceReference. More...
|
|
template<typename TMessageType > |
MessageSubscriptionToken | addTunnelingFilter (const TMessageType &messageType, typename TMessageType::FunctionType function) |
| Adds a message filter where the filter is a function. More...
|
|
template<typename TMessageType , typename TClass , typename TClassMethod > |
MessageSubscriptionToken | addTunnelingFilter (const TMessageType &messageType, TClass *messageHandlerObject, TClassMethod method) |
| Adds a message filter where the filter is a method that is invoked on an object. More...
|
|
template<typename TMessageType > |
MessageSubscriptionToken | addTunnelingHandler (const TMessageType &messageType, typename TMessageType::FunctionType function, Node *messageSourceFilter) |
| Adds a message handler where the handler is a function and you explicitly define the accepted source. More...
|
|
AppliedStyleEntrySharedPtr | applyManualStyle (StyleSharedPtr style) |
| Applies a style to an object node. More...
|
|
AppliedStyleEntrySharedPtr | applyStyle (StyleSharedPtr style) |
| Applies a style to an object node. More...
|
|
void | applyStyles () |
| Apply all styles for an object node. More...
|
|
void | applyStylesRecursive () |
| Applies styles recursively. More...
|
|
void | attachRecursive () |
| Attaches an object node and its children recursively. More...
|
|
InputManipulatorConstIterator | beginInputManipulators () const |
|
NodeComponentConstIterator | beginNodeComponents () const |
|
void | clearChangeFlag (uint32_t flag) |
| Clears a change flag. More...
|
|
void | clearChildChangeFlag (uint32_t flag) |
| Clears a child change flag. More...
|
|
bool | containsResource (const ResourceID &resourceID) const |
| Returns if object node resource dictionary contains the resource with given ID. Resource can be any type: style, alias or resource manager resource. */. More...
|
|
BindingLookupContextPtr | createLookupContext (NodeSharedPtr templateRoot) |
| Creates a lookup context for the node. More...
|
|
void | detachRecursive () |
| Detaches a node and its descendants. More...
|
|
void | dispatchAbstractMessage (const AbstractMessageType &messageType, MessageArguments &messageArguments) |
| Dispatches a message from this node with specified arguments. More...
|
|
template<typename TArgumentsType > |
void | dispatchMessage (const MessageType< TArgumentsType > &messageType, typename MessageType< TArgumentsType >::ArgumentsType &messageArguments) |
| Dispatches a message from this node with specified arguments. More...
|
|
InputManipulatorConstIterator | endInputManipulators () const |
|
NodeComponentConstIterator | endNodeComponents () const |
|
template<typename TNodeType > |
shared_ptr< TNodeType > | findAbstractChild (string_view name) |
| Find a child by name. Finds direct children as well as children connected indirectly for example Viewport->Scene. More...
|
|
optional< string > | findResourceURL (const ResourceID &resourceId) const |
| Tries to find Resource URL for Resource ID from this node. More...
|
|
template<typename DataType > |
DataType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
|
uint32_t | getChangeFlags () const |
| Get current change flags. More...
|
|
uint32_t | getChildChangeFlags () const |
| Get current child change flags. More...
|
|
FocusManager * | getFocusManager () const |
| Returns the Focus Manager associated with the Screen node to which this node belongs. More...
|
|
FocusScope * | getFocusScopeInfo () const |
| Returns the information about the focus scope for a node. More...
|
|
InputManager * | getInputManager () const |
| Returns the Input Manager associated with the Screen node to which this node belongs. More...
|
|
AbstractPropertyTypeDescriptor::ValueSource * | getNodeFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const |
|
template<typename DataType > |
optional< typename PropertyType< DataType >::DataType > | getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const |
|
template<typename DataType > |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalProperty (const PropertyType< DataType > &propertyType) const |
| Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
|
|
Node * | getParent () const |
| Returns the parent of the node. More...
|
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property. More...
|
|
ResourceDictionarySharedPtr | getResourceDictionary () const |
| If a node has a resource dictionary, returns the resource dictionary of that node. More...
|
|
Screen * | getScreen () const |
| Returns the Screen node to which this node belongs. More...
|
|
NodeSharedPtr | getTemplateRoot () const |
| Gets the template root of this node. More...
|
|
void | invalidateArrange () |
| Invalidates arrange. More...
|
|
void | invalidateDraw () |
| Invalidates draw flag for the node. More...
|
|
void | invalidateFinalTransform () |
| Invalidates final transform for node. More...
|
|
void | invalidateMeasure () |
| Invalidates measure for the node. More...
|
|
void | invalidateRender () |
| Invalidates render for node. More...
|
|
bool | isAnyChangeFlagSet (uint32_t flag) const |
| Checks if any of given flags is set. More...
|
|
bool | isAnyChildChangeFlagSet (uint32_t flag) const |
| Checks if any child change flags (corresponding to given mask) are set. More...
|
|
bool | isAttached () const |
| Returns true if the node is attached to a screen or one of its descendants. More...
|
|
bool | isAttaching () const |
| Returns true if node is in the process of attaching, false otherwise. More...
|
|
bool | isChangeFlagSet (uint32_t flag) const |
| Checks if a change flag is set. More...
|
|
bool | isChildChangeFlagSet (uint32_t flag) const |
| Checks if child change flags match. More...
|
|
bool | isDetaching () const |
| Returns true if the node currently detaching. More...
|
|
bool | isEffectivelyFocusable () const |
| Returns whether a node is focusable. More...
|
|
bool | isEffectivelyVisible () const |
| Returns whether a node and its ancestor nodes are visible. More...
|
|
bool | isInitialized () const |
| Returns true if initialize() has been called, false otherwise. More...
|
|
bool | isInvalidArrange () const |
| Checks if the node needs arrange. More...
|
|
bool | isInvalidDraw () |
| Tells if node draw flag is invalid. More...
|
|
bool | isInvalidFinalTransform () const |
| Tells if final transform flag is invalid for node. More...
|
|
bool | isInvalidMeasure () const |
| Check if the node needs measure. More...
|
|
bool | isInvalidRender () const |
| Returns if node render flag is invalid. More...
|
|
bool | isNamed (string_view name) const |
|
| KZ_METACLASS_PROPERTY_TYPE (FontFamilyProperty) |
|
template<typename Type > |
shared_ptr< Type > | lookupNode (string_view pathOrKey) |
| Returns a node of specified type by looking it up with specified path or alias. More...
|
|
template<typename Type > |
shared_ptr< Type > | lookupNodeComponent (string_view name) |
| Returns a node component of specified type by looking it up with specified name. More...
|
|
Node * | lookupNodeRaw (string_view relativePath) |
| Get an object node by another node and a relative path. More...
|
|
ObjectSharedPtr | lookupObject (string_view relativePath) |
| Lookup for an object from a node. More...
|
|
template<typename Type > |
shared_ptr< Type > | lookupObject (string_view relativePath) |
| Lookup for an object from a node. More...
|
|
tuple< NodeSharedPtr, AbstractPropertyType > | lookupObjectForStateManager (string_view relativePath) |
| Lookup for an node and possible object from within the node for state manager. More...
|
|
void | notifyResourceDictionaryModified () |
| Forces the re-evaluation of resource IDs in a node tree. More...
|
|
void | removeAnonymousResource (const Resource &resource) |
| Removes anonymous resource from object node resources. More...
|
|
void | removeInputManipulator (InputManipulator &inputManipulator) |
| Removes the ownership and detaches an input manipulator from an object node. More...
|
|
void | removeKZBData (flat_set< AbstractPropertyType > *keepProperties) |
| Destroys all object node data loaded from KZB, including properties, bindings, node components, resources etc. More...
|
|
void | removeKZBData () |
| Destroys all object node data loaded from KZB. More...
|
|
void | removeMessageHandler (MessageSubscriptionToken token) |
| Removes a message subscription. More...
|
|
void | removeNodeComponent (NodeComponent &nodeComponent) |
| Removes the ownership of a node component from an object node. More...
|
|
void | removeNodeComponentWithOwner (const void *owner) |
| Removes all bindings with the specified owner. More...
|
|
void | removeNodeReference (const AbstractNodeReference &reference) |
|
void | removeResource (const ResourceID &resourceId) |
| Removes a resource with given ID from object node resource dictionary. Does not do anything if resourceID was not found. */. More...
|
|
void | removeResourceReference (const AbstractResourceReference &reference) |
| This is a helper for automatic resource tracking in ResourceReference. More...
|
|
void | setChangeFlag (uint32_t flag) |
| Sets a change flag. More...
|
|
void | setChildChangeFlag (uint32_t flag) |
| Sets a child change flag. More...
|
|
void | setParent (Node *parent) |
| Kanzi uses this method internally to set the parent of a node. More...
|
|
void | setResourceDictionary (ResourceDictionarySharedPtr resourceDictionary) |
| Replaces the resource dictionary of a node. More...
|
|
void | setScreen (Screen *screen) |
| Sets the Screen node to which this node belongs. More...
|
|
void | setTemplateRoot (NodeSharedPtr templateRoot) |
| Sets the template root of this node. More...
|
|
ResourceSharedPtr | tryAcquireResource (const ResourceID &id) const |
| Acquires a resource from the node or the node's closest ancestor having the resource id in the resource dictionary. More...
|
|
template<typename T > |
shared_ptr< T > | tryAcquireResource (const ResourceID &id) const |
| Acquires a resource from the node or the node's closest ancestor having the resource and casts the resource to given type. More...
|
|
KZ_DEPRECATED NodeSharedPtr | trySetActiveFocus () |
| Tries to move the focus on this node. More...
|
|
NodeSharedPtr | trySetFocus () |
| Tries to move the focus to this node. More...
|
|
NodeSharedPtr | trySetFocus (FocusFallback fallbackOption) |
| Tries to set the focus to the newFocusNode using FocusManager::trySetFocus() but with a fallback behavior in case the node does not gain focus. More...
|
|
void | unapplyStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
| Unapplies a style from an object node. More...
|
|
void | unapplyStyles () |
| Unapplies and removes all applied styles. More...
|
|
void | unapplyStylesRecursive () |
| Unapplies styles recursively. More...
|
|
void | validateArrange () |
| Validates arrange. More...
|
|
void | validateDraw () |
| Validates draw flags for the node. More...
|
|
void | validateDrawForChildrenRecursive () |
| Recursively validates draw for the children from this 2D node onwards. More...
|
|
void | validateMeasure () |
| Validates measure for the node. More...
|
|
void | validateRender () |
| Validates render for node. More...
|
|
VisitorResult | visit (const Visitor &visitor, VisitorOrder order) |
| Visits a node and its descendants. More...
|
|
VisitorResult | visitDescendants (const Visitor &visitor, VisitorOrder order) |
| Visits the descendants of a node. More...
|
|
| ~Node () override |
| Destructor. More...
|
|
string | getName () const |
| Gets the value of NameProperty. More...
|
|
void | setName (string_view value) |
| Sets the value of NameProperty. More...
|
|
string | getPath () const |
| Gets the value of PathProperty. More...
|
|
void | setPath (string value) |
| Sets the value of PathProperty. More...
|
|
string | getLocale () const |
| Gets the value of LocaleProperty. More...
|
|
void | setLocale (string value) |
| Sets the value of LocaleProperty. More...
|
|
bool | isHitTestable () const |
| Gets the value of HitTestableProperty. More...
|
|
void | setHitTestable (bool value) |
| Sets the value of HitTestableProperty. More...
|
|
bool | isHitTestableContainer () const |
| Gets the value of HitTestableContainerProperty. More...
|
|
void | setHitTestableContainer (bool value) |
| Sets the value of HitTestableContainerProperty. More...
|
|
bool | isVisible () const |
| Gets the value of VisibleProperty. More...
|
|
void | setVisible (bool value) |
| Sets the value of VisibleProperty. More...
|
|
bool | isEnabled () const |
| Returns the value of the EnabledProperty. More...
|
|
void | setEnabled (bool value) |
| Sets the value of the EnabledProperty. More...
|
|
bool | isEffectivelyEnabled () const |
| Returns the value of EffectivelyEnabledProperty. More...
|
|
bool | isFocusable () const |
| Gets the value of the FocusableProperty. More...
|
|
void | setFocusable (bool value) |
| Sets the value of the FocusableProperty. More...
|
|
bool | isFocused () const |
| Gets the value of the FocusedProperty. More...
|
|
void | setFocused (bool value) |
| Sets the value of the FocusedProperty. More...
|
|
FocusState | getFocusState () const |
| Gets the value of the FocusStateProperty. More...
|
|
void | setFocusState (FocusState state) |
| Sets the value of the FocusStateProperty. More...
|
|
FontFamilySharedPtr | getFontFamily () const |
| Gets the font family the node uses. More...
|
|
void | setFontFamily (FontFamilySharedPtr value) |
| Sets the font family the node uses. More...
|
|
float | getVisibleAmountInParent () const |
| Gets the value of VisibleAmountInParentProperty. More...
|
|
void | setVisibleAmountInParent (float value) |
| Sets the value of VisibleAmountInParentProperty. More...
|
|
float | getProjection2DTo3DScale () const |
| Gets the value of Projection2DTo3DScaleProperty. More...
|
|
void | setProjection2DTo3DScale (float value) |
| Sets the value of Projection2DTo3DScaleProperty. More...
|
|
ResourceSharedPtr | getStyle () const |
| Gets the value of StyleProperty. More...
|
|
void | setStyle (ResourceSharedPtr value) |
| Sets the value of StyleProperty. More...
|
|
ResourceSharedPtr | getStateManager () const |
| Gets the value of StateManagerProperty. More...
|
|
void | setStateManager (ResourceSharedPtr value) |
| Sets the value of StateManagerProperty. More...
|
|
float | getWidth () const |
| Gets the value of WidthProperty. More...
|
|
void | setWidth (float value) |
| Sets the value of WidthProperty. More...
|
|
float | getHeight () const |
| Gets the value of HeightProperty. More...
|
|
void | setHeight (float value) |
| Sets the value of HeightProperty. More...
|
|
float | getDepth () const |
| Gets the value of DepthProperty. More...
|
|
void | setDepth (float value) |
| Sets the value of DepthProperty. More...
|
|
float | getActualWidth () const |
| Gets the value of ActualWidthProperty. More...
|
|
void | setActualWidth (float value) |
| Sets the value of ActualWidthProperty. More...
|
|
float | getActualHeight () const |
| Gets the value of ActualHeightProperty. More...
|
|
void | setActualHeight (float value) |
| Sets the value of ActualHeightProperty. More...
|
|
float | getActualDepth () const |
| Gets the value of ActualDepthProperty. More...
|
|
void | setActualDepth (float value) |
| Sets the value of ActualDepthProperty. More...
|
|
Node::HorizontalAlignment | getHorizontalAlignment () const |
| Gets the value of HorizontalAlignmentProperty. More...
|
|
void | setHorizontalAlignment (Node::HorizontalAlignment value) |
| Sets the value of HorizontalAlignmentProperty. More...
|
|
Node::VerticalAlignment | getVerticalAlignment () const |
| Gets the value of VerticalAlignmentProperty. More...
|
|
void | setVerticalAlignment (Node::VerticalAlignment value) |
| Sets the value of VerticalAlignmentProperty. More...
|
|
Node::DepthAlignment | getDepthAlignment () const |
| Gets the value of DepthAlignmentProperty. More...
|
|
void | setDepthAlignment (Node::DepthAlignment value) |
| Sets the value of DepthAlignmentProperty. More...
|
|
Vector2 | getHorizontalMargin () const |
| Gets the value of HorizontalMarginProperty. More...
|
|
void | setHorizontalMargin (Vector2 value) |
| Sets the value of HorizontalMarginProperty. More...
|
|
Vector2 | getVerticalMargin () const |
| Gets the value of VerticalMarginProperty. More...
|
|
void | setVerticalMargin (Vector2 value) |
| Sets the value of VerticalMarginProperty. More...
|
|
Vector2 | getDepthMargin () const |
| Gets the value of DepthMarginProperty. More...
|
|
void | setDepthMargin (Vector2 value) |
| Sets the value of DepthMarginProperty. More...
|
|
Node::ContentStretch | getContentStretch () const |
| Gets the value of ContentStretchProperty. More...
|
|
void | setContentStretch (Node::ContentStretch value) |
| Sets the value of ContentStretchProperty. More...
|
|
float | getOpacity () const |
| Gets the value of OpacityProperty. More...
|
|
void | setOpacity (float value) |
| Sets the value of OpacityProperty. More...
|
|
bool | isHover () const |
| Returns whether the node has HoverProperty set to true. More...
|
|
bool | isClipChildren () const |
| Gets the value of ClipChildrenProperty. More...
|
|
void | setClipChildren (bool value) |
| Sets the value of ClipChildrenProperty. More...
|
|
AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
| Applies a style to an object. More...
|
|
void | applyObjectStyles () |
| Apply all styles for an object node. More...
|
|
Domain * | getDomain () const |
| Returns the domain the object belongs to. More...
|
|
const Metaclass * | getDynamicMetaclass () const override |
| Returns the metaclass of the dynamic type of the object. More...
|
|
MainLoopScheduler * | getMainLoopScheduler () const |
| Returns the MainLoopScheduler instance of the associated Domain. More...
|
|
detail::MessageDispatcher * | getMessageDispatcher () const |
| Returns the message dispatcher of the object. More...
|
|
ResourceManager * | getResourceManager () const |
| Returns the resource manager of the object. More...
|
|
ScriptingContextSharedPtr | getScriptingContext () const |
| Gets the scripting context of the object. More...
|
|
| Object (Domain *domain) |
|
void | setScriptingContext (ScriptingContextSharedPtr context) |
| Sets the scripting context of the object. More...
|
|
void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
|
void | unapplyObjectStyles () |
| Unapplies and removes all applied styles. More...
|
|
| ~Object () override |
|
bool | isTypeOf (const Metaclass *objectType) const |
| Determines if the type of this object is the given type or derived from it. More...
|
|
virtual | ~MetaObject () |
|
template<typename DataType > |
void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
|
template<typename DataType > |
void | addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| Adds a property modifier without notifying handlers. More...
|
|
template<typename DataType > |
void | addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
|
template<typename DataType > |
void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer) |
|
template<typename DataType > |
void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
|
PropertyStorageContainer::iterator | beginPropertyStorage () |
| Returns the begin iterator to the internal property storage container. More...
|
|
PropertyStorageContainer::const_iterator | beginPropertyStorage () const |
| Returns the begin iterator to the internal property storage container. More...
|
|
void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
|
void | copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType) |
| Copies local value of single property from another object. More...
|
|
void | copyLocalValues (const PropertyObject &other) |
| Copies all local values from another object. More...
|
|
PropertyStorageContainer::iterator | endPropertyStorage () |
| Returns the end iterator to the internal property storage container. More...
|
|
PropertyStorageContainer::const_iterator | endPropertyStorage () const |
| Returns the end iterator to the internal property storage container. More...
|
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const |
|
template<typename DataType > |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const |
|
template<typename DataType > |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalProperty (const PropertyType< DataType > &propertyType) const |
| Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
|
|
template<typename DataType > |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value. More...
|
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property type. More...
|
|
template<typename DataType > |
PropertyType< DataType >::Traits::ReturnType | getPropertyBase (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property disregarding modifiers. More...
|
|
template<typename DataType > |
size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const |
| Gets number of current notification handlers for given property type. More...
|
|
bool | hasBaseValue (AbstractPropertyType propertyType) const |
| Evaluates whether there are any inputs into the property value, disregarding modifiers. More...
|
|
bool | hasLocalValue (AbstractPropertyType propertyType) const |
| Evaluates whether there is a local value set for the property. More...
|
|
bool | hasNonClassValue (AbstractPropertyType propertyType) const |
| Evaluates whether there is a value of any precedence higher than class default value set for the property. More...
|
|
bool | hasValue (AbstractPropertyType propertyType) const |
| Evaluates whether there are any inputs into the property value. More...
|
|
bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
|
| PropertyObject () |
|
void | removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties) |
| Remove all KZB properties that are not included in a given set. More...
|
|
void | removeKzbProperties () |
| Remove all KZB properties. More...
|
|
template<typename DataType > |
void | removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
|
void | removeLocalValue (AbstractPropertyType propertyType) |
| Removes the local value associated with the property. More...
|
|
template<typename DataType > |
void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
|
template<typename DataType > |
void | removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
|
template<typename DataType > |
void | removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
|
template<typename DataType > |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
|
template<typename DataType > |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
| Sets the local value of a property type. More...
|
|
void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
|
KZ_DEPRECATED void | validatePropertyModifiers (AbstractPropertyType propertyType) |
| Validates property modifiers and notifies handlers. More...
|
|
void | validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType) |
| Validates property modifiers and notifies handlers. More...
|
|
virtual | ~PropertyObject () |
|
void | addBindingRuntime (AbstractBindingRuntimeSharedPtr entry, shared_ptr< void > owner) |
| Adds an already-created binding runtime to this binding host. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyValuePrecedence precedence) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyValuePrecedence precedence) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType) |
| Wrapper for setting a binding. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot) |
| Sets a binding with no target. More...
|
|
BindingRuntimeHandle | setBinding (AbstractBindingSharedPtr binding) |
| Wrapper for setting a binding with no target. More...
|
|
BindingRuntimeHandle | setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence) |
| Sets a binding to a certain property. More...
|
|
BindingRuntimeHandle | setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence) |
| Wrapper for setting a binding with owner. More...
|
|
BindingRuntimeHandle | setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType) |
| Wrapper for setting a binding with owner. More...
|
|
BindingRuntimeHandle | setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot) |
| Sets a binding with no target. More...
|
|
BindingRuntimeHandle | setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner) |
| Wrapper for setting a binding with no target. More...
|
|
BindingRuntimeHandle | setModifierBinding (AbstractBindingSharedPtr binding, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field) |
| Wrapper for setting a modifier binding. More...
|
|
BindingRuntimeHandle | setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field) |
| Wrapper for setting a modifier binding. More...
|
|
BindingRuntimeHandle | setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType) |
| Wrapper for setting a modifier binding. More...
|
|
BindingRuntimeHandle | setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< Node > templateRoot, AbstractPropertyType propertyType, PropertyField field) |
| Sets a modifier binding. More...
|
|
BindingRuntimeHandle | setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field) |
| Wrapper for setting a modifier binding. More...
|
|
BindingRuntimeHandle | setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType) |
| Wrapper for setting a modifier binding. More...
|
|
BindingRuntimeConstIterator | beginBindingRuntimes () const |
| Returns an iterator to the beginning of binding runtimes. More...
|
|
BindingRuntimeConstIterator | endBindingRuntimes () const |
| Returns an iterator to the end of binding runtimes. More...
|
|
AbstractBindingRuntimeSharedPtr | getBindingRuntime (size_t idx) |
| Gets binding by index. More...
|
|
size_t | getBindingRuntimeCount () const |
| Gets the number of binding runtimes added to this node. More...
|
|
void | removeAllBindings () |
| Removes all binding runtimes. More...
|
|
void | removeBinding (BindingRuntimeHandle &bindingRuntime) |
| Removes a binding runtime added earlier. More...
|
|
void | removeBindingsWithOwner (shared_ptr< void > owner) |
| Removes all binding runtimes with the specified owner. More...
|
|
Node2D is the base class of 2D nodes.
Node2D implements functionality common to all 2D nodes, such as rendering, layouting, and hit testing.
To create UI graphs, use classes derived from Node2D, such as Image2D, EmptyNode2D, and StackLayout2D. To implement your own custom rendering and layout, derive from Node2D.
You can use methods of the Node2D class to configure common parameters for rendering and layout. Use methods of the derived classes to control behavior specific to them.
Creating nodes
To create a 2D node, call a create function that returns a shared pointer to the node.
To create an EmptyNode2D node:
To create an Image2D node:
Each node has its own type of create function.
The constructors of nodes are protected, and can be accessed only by the inheriting classes. Node initialization happens within the create function, after constructing the node.
Node tree
Kanzi arranges nodes in a tree that you can think of as a directed acyclic graph with no loops. Each node can have multiple children but only one parent.
The root node of the node tree is always a 2D node. The root node does not have a parent, and it is usually of type Screen.
The Viewport2D node serves as a window to a 3D scene graph that Kanzi displays in the viewport area. A Viewport2D node must have a child Scene node as the root of the 3D scene graph. The child nodes of the Scene node are Node3D nodes.
Constructing the node tree
You can manipulate the node tree by adding children to nodes:
parentNode->addChild(childNode);
You can remove children from a parent node:
parentNode->removeChild(*childNode);
Parents take ownership, and hold a reference to the children.
Iterating the node tree
You can explore the node tree from a node by iterating its children:
{
stream << (*it)->getName() << "::";
}
You can also go upwards to the parent:
Node2D* parent = dynamic_cast<Node2D*>(child1->getParent());
The parent returned is valid except for the root node that has no parent (it returns nullptr).
Finding nodes
Finding nodes in the node tree is inherited from Node base class. You can look for nodes with a path:
The paths work relative from the node doing the lookup. You can also traverse upwards:
If lookup fails, no node is returned. See node tree lookup in Node documentation.
Rendering
Kanzi renders nodes starting from the root node of the node tree, iterating the tree in depth-first algorithm.
A 2D node has a foreground and a background. Kanzi renders the foreground and background separately. Node classes can override the foreground or background rendering separately.
Foreground is the content of the node. For example, an image.
Background is the full node area. The background can be of the same size as the node content, or larger.
To fit the content to the node area, use the ContentStretchProperty.
Rendering order
Kanzi renders nodes in the order in which you add the nodes to the parent node. The node that you add first is rendered first.
You can modify the rendering order by reordering the child nodes within a parent node.
To render a node last, move that node to the front:
To render a node first, move that node to the back:
Kanzi always renders the content of a parent node before rendering its child nodes.
Brushes
Kanzi uses brushes to render the foreground, background, and the optional composition of a node. Brushes determine how Kanzi does the rendering. A brush can display a color or an image, tint content provided by the node, or use an arbitrary shader to render the content of a node.
A 2D node can have a foreground brush, background brush, and a composition brush. Use the ForegroundBrushProperty, BackgroundBrushProperty, and CompositionBrushProperty to access the brushes.
To set the foreground brush of a 2D node:
textNode->setForegroundBrush(
ColorBrush::create(domain,
"color brush", ColorRGBA(0.5f, 1.0f, 0.5f, 1.0f)));
Use the foreground brush to render the content that the node provides. For example, an Image2D node provides an image. If a node does not provide foreground content, setting the foreground brush has no effect. Most 2D nodes render on top of the background an empty foreground of the same size as the background. For example, the EmptyNode2D node.
To set the background brush of a 2D node:
empty->setBackgroundBrush(
ColorBrush::create(domain,
"color brush", ColorRGBA(0.8f, 1.0f, 0.2f, 1.0f)));
Use the background brush to render the content outside and behind the node foreground area. If the node has no foreground or the foreground is translucent, the background fills the entire node area. If the foreground is opaque and fills the entire node area, Kanzi does not render the background.
To disable rendering, set null brush:
Note that some node types have default brushes, which is why removing the brush property is not enough to disable rendering. Instead, Kanzi renders the node using the default brush.
Opacity
To control the translucency of a node, use the OpacityProperty. You can set the opacity of a node:
Opacity affects node background, foreground, and all node children.
When the brushes or content of a 2D node are translucent, the foreground and background of that node can be translucent even when you do not set the OpacityProperty.
Setting a 2D node as translucent affects all children of that node. To render overlapping translucency in the child nodes correctly, it is possible that you have to composite the parent node. See Composition.
Render transformation
To set the rendering position of a node relative to its parent, use the RenderTransformationProperty:
node->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), -1.570796f, Vector2(50.0f, 0.0f)));
Kanzi specifies the render transformation as SRT, that is, Scale, Rotation, and Translation.
By default, Kanzi performs the render transformation of a 2D node relative to the top-left corner of that node. To set the origin of the render transformation within the node, use the RenderTransformationOriginProperty:
node->setRenderTransformationOrigin(Vector2(0.5f, 0.5f));
You can also set the render transformation origin outside the node:
node->setRenderTransformationOrigin(Vector2(-3.0f, 1.0f));
The values set to render transform origin are relative to the size of the node. For example, the value 0.5 ; 0.5 sets the origin at the center of the node.
Kanzi applies the render transformation after applying layout transformation. Render transformation is not affected by layout constraints such as alignment and margins, and does not modify the size layout nodes take into account. See Layout transformation.
Perspective transformation
To bring limited 3D effects to a 2D node tree, you can apply perspective transformation in 3D space. Perspective transformation is an optional transformation that Kanzi applies as the last Node2D transformation, after the layout and render transformations.
To set the perspective transformation:
node->setPerspectiveTransformation(SRTValue3D(Vector3(1.0f, 1.0f, 1.0f), Vector3(0.0f, 0.2f, 0.0f), Vector3(0.0f, 0.0f, 0.0f)));
Kanzi applies the projection for perspective transformation in the space of the current composition space. Kanzi specifies the perspective transformation as 3D SRT, that is, 3-component Scale, Rotation, and Translation vectors.
NodeVisual2D
Kanzi stores in an object of type NodeVisual2D all information related to the foreground and background rendering in Node2D. NodeVisual2D holds the brush and geometry information that Kanzi needs to render 2D node. To save memory, if node has nothing to render, Kanzi does not allocate a visual component.
Once the visual component is allocated, Node2D never releases it.
Composition
By default, Kanzi renders a 2D node into the rendering context of the parent node. Usually, the top-level rendering context is the backbuffer, provided by the Screen node.
You can manually override this and render a node into a render target:
emptyNode->setRenderTarget(renderTarget);
When you specify the render target, the node takes its size from the render target size. You can define fixed width and fixed height for a node that also has a render target set. The fixed size can be smaller than the size of the render target. In this case, rendering happens only on a part of the render target area. Specifying a fixed size larger than the render target size is undefined behavior. A node that Kanzi renders into a render target also draws the resulting composition to the rendering context of their parent.
To achieve the correct rendering result, in some cases, Kanzi automatically renders nodes using a render target.
If the opacity of a Viewport2D is not 1.0 or if its transformation has non-translation components, that Viewport2D renders to a render target:
viewportNode->setRenderTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.2f, Vector2(0.0f, 0.0f)));
bool isInCompositionTarget = viewportNode->isSelfInCompositionTarget();
Viewport2D is a 'window' to a 3D scene. It must be aligned to the units in the parent render context. If this is not the case, it needs to be composited.
All nodes render to render targets if they have children and their opacity is not one:
parentNode->addChild(childNode);
parentNode->setOpacity(0.8f);
bool isInCompositionTarget = parentNode->isSelfInCompositionTarget();
The parent has opacity set, so it will first need to do composition of all its children, and then render this composition using that opacity.
When you assign a render target manually, you can set that render target to take its size from the size of the node. In this case, Kanzi resizes the composition target to the size that the node gets during layout:
screen->attach();
node->setWidth(static_cast<float>(width));
node->setHeight(static_cast<float>(height));
screen->addChild(node);
node->setBackgroundBrush(brush);
textureCreateInfo.widthDivisor = 1;
textureCreateInfo.heightDivisor = 1;
node->setRenderTarget(renderTarget);
node->setOffscreenRendering(true);
{
CompositionStack& compositionStack = renderer->getCompositionStack();
screen->setAllocatedSize(Vector2(static_cast<float>(width), static_cast<float>(height)));
screen->setArrangeTransform(Matrix3x3());
screen->layout();
compositionStack.pushComposition(0, screen->getAllocatedSize());
screen->render(*renderer, compositionStack);
compositionStack.popComposition();
}
screen->detach();
Offscreen rendering
Nodes do not necessarily have to draw their composition onto the render context of their parent. To enable offscreen rendering:
emptyNode->setOffscreenRendering(true);
When you enable offscreen rendering, Kanzi does not draw the node anywhere after rendering to its render target.
You can render the render target of the node using some other node:
imageNode->setImage(emptyNode->getRenderTarget());
The render target behaves like a normal texture when used. Setting the render target to an Image2D determines its size unless you set the render target to use fixed size.
Clearing a render target
When Kanzi renders a Node2D to a render target, it clears the color and depth buffers of that render target. If the render target has a depth buffer, and the node is not a Viewport2D that clears it in a RenderPass, Kanzi clears the depth buffer. If the foreground of the node does not fill the complete composition area, or the combination of background and foreground is translucent, Kanzi clears the color buffer.
To disable the clearing of a render target:
emptyNode->setDisableRenderTargetClear(true);
When you disable the clearing of a render target, you prevent the node from clearing the render target even if the node would otherwise do it.
By default, Kanzi clears all render targets. This simplifies the rendering code and increases performance on GPUs that use tiled renderers.
Caching
To avoid rendering a 2D node and its descendants every frame, you can cache the rendering results of a 2D node. Caching carries a cost in GPU memory. Cache only complex nodes that are expensive to render and change rarely. You can either:
- Let Kanzi update the cache automatically whenever the node or any of its descendants change.
- Make Kanzi use the same cache until you manually invalidate that cache.
To control the caching of a 2D node, use the CachingModeProperty. You can enable or disable the cache:
When the CachingModeProperty is set to CachingModeEnabled, the node content does not change until you either:
To invalidate the cache:
parentNode->resetCache();
After you invalidate the cache, Kanzi renders the node content once. After this, Kanzi considers the node cached again. You can disable the cache:
After you disable the cache, Kanzi renders the node normally and all changes to the node and its descendants are visible immediately.
Setting the CachingModeProperty to CachingModeAutomatic causes Kanzi to automatically update the cache of the node whenever the content of the node or its descendants change. To set Kanzi to automatically update the cache:
When the caching mode is set to automatic, any change to the node or its descendants causes Kanzi to update the cache. You can manually set the draw flag on a child node to invalidate the cache:
imageChildNode->setOpacity(1.0f);
Setting any property that controls rendering will eventually invalidate draw.
NodeCompositor2D
Kanzi stores in NodeCompositor2D all information related to compositing. This object holds composition targets, caching information, and a composition brush. Because compositing implies rendering, it is not possible to allocate a compositor without also allocating a NodeVisual2D. To save memory, if composition is not needed, Kanzi does not allocate a compositor component.
Once the compositor component is allocated, Node2D never releases it. Composition targets within compositor can be released if not needed.
Basic Layout
A 2D node tries to determine its size automatically. A 2D node with content by default takes the size of its content. For example, Image2D takes the size of the image that it displays. EmptyNode2D and Viewport2D have unbounded layout by default. This means that they take the entire available size. Kanzi calculates the available size from the size of the parent node, or the available screen area. To arrange nodes in a layout, use layout control nodes such as StackLayout2D or GridLayout2D.
To set the size of a 2D node:
node->setWidth(160.0f);
node->setHeight(90.0f);
To set a 2D node to determine its size automatically, remove the fixed size:
node->setAutoWidth();
node->setAutoHeight();
or:
You can configure a node to take its width or height based on a specified fixed size and an aspect ratio:
node->setAspectRatio(1.777778f);
If fixed width and aspect ratio are defined, height is width divided by aspect ratio. If fixed height and aspect ratio are defined, width is height multiplied by aspect ratio. If both fixed width and fixed height are defined, aspect ratio has no effect.
If neither width or height are defined, but aspect ratio is defined, the result depends on the node. A node that has unbounded layout takes the largest size it can with the given aspect ratio while still fitting within its allocated size. Aspect ratio has no effect when the content of a node defines its size. This is analogous to having both fixed width and fixed height.
A 2D node has an allocated area specified by the area of the parent node or a layout node. You can configure a 2D node to align in its allocated area by setting horizontal and vertical alignment:
Available values for horizontal alignment are:
Available values for vertical alignment are:
You can configure 2D node to fill its allocated area by setting alignment to stretch:
You can offset a 2D node from the edges of its parent node:
node->setHorizontalMargin(Vector2(20.0f, 10.0f));
node->setVerticalMargin(Vector2(20.0f, 10.0f));
For horizontal margins, the order of values is left, then right. For vertical margins, the order of values is top, then bottom. Kanzi offsets the node from the edge of its allocated area by the amount equal to the margin that you set. When you do not set the margins, Kanzi aligns the node at the edge of allocated area.
Layout transformation
To set the transformation of a node relative to its parent node, set the LayoutTransformationProperty:
node->setLayoutTransformation(SRTValue2D(Vector2(1.0f, 1.0f), 0.7853982f, Vector2(0.0f, 0.0f)));
Kanzi specifies the layout transform as SRT, that is, Scale, Rotation, and Translation.
When you transform a node with layout transformation, Kanzi applies alignment and margins to that node after the transformation. Kanzi applies render transformation after layout transformation, alignment, and margins.
See Render transformation and Perspective transformation.
Content stretch
The foreground content, such as an image, of a 2D node, has rules on how to stretch in relation to the node area.
These are the available content stretch modes:
ContentStretchNone centers the foreground area in the node area and keeps the exact size of the content.
If the node is smaller than the foreground area, it displays only a part of the content.
If the node is larger than the foreground area, the remaining area is left for background rendering.
ContentStretchFill sets the foreground area to take the exact node area.
This can change the aspect ratio of the content.
ContentStretchUniform sets the foreground content to stretch to fill the node area while keeping its aspect ratio.
If the aspect ratio of the node is different from content aspect ratio, the remaining area is left for background rendering.
This is the default content stretch mode.
ContentStretchUniformToFill centers the foreground area relative to the node area and scales the foreground uniformly to fill the node area.
If the aspect ratio of the node is different from the content aspect ratio, the node displays only part of the content.
To set the content stretch mode:
Layout in main loop
During the main loop of the application, Kanzi calls layout for the root node. Before calling layout, Kanzi sets the allocated size of the Screen node to the size of the current graphics output. The layout pass evaluates only nodes that are marked as requiring layout. Kanzi calls render immediately after layout.
Because Kanzi calls render immediately after layout, you can modify the node tree and see the changes before the next call to the update function. It can be useful to determine the calculated sizes or locations of nodes before waiting for the next frame. To call layout manually:
screen->addChild(node);
screen->setAllocatedSize(Vector2(1280.0f, 720.0f));
screen->layout();
After calling layout(), you can call getActualSize() to get the size determined by the node. Default allocated size is unbounded layout or infinity. When calling layout() manually, you must set the allocated size for the node that receives the layout() call.
See Implementing a custom 2D node - Layout.
Hit testing
You can hit test nodes in regard to their location on screen:
parentNode->addChild(childNode);
parentNode->setWidth(400.0f);
parentNode->setHeight(300.0f);
screen->layout();
Hit testing uses the 'world' or 'render' coordinates of the node. These coordinates are relative to the screen, not to the parent node or to the node that does the hit testing. Hit testing takes into account the visibility and all transformations of a node.
Hit testing transforms global coordinates into Node2D local coordinates to determine if the node is hit. You can determine world (screen) space coordinates in the local coordinate space of a 2D node:
optional<Vector2> localCoords = childNode->globalToLocal(Vector2(50.0f, 40.0f));
The return value is enclosed in an optional value, but is always valid if the node has a real nondegenerate transformation.
You can test whether given coordinates hit a node:
optional<Vector2> localCoords = childNode->containsGlobal(Vector2(50.0f, 40.0f));
Checking whether a global coordinate is within a node is equal to calling globalToLocal() and then testing the result with containsLocal().
Implementing a custom 2D node
To do custom rendering and layout, you can implement a custom 2D node.
Defining the class
To define a custom Node2D implementation, inherit from the Node2D base class.
To define a Node2D implementation:
class ExampleNode2D;
typedef shared_ptr<ExampleNode2D> ExampleNode2DSharedPtr;
{
public:
static PropertyType<float> ExampleProperty;
float getExampleProperty() const
{
}
void setExampleProperty(float value)
{
}
class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
};
static MessageType<ExampleMessageArguments> ExampleMessage;
static ExampleNode2DSharedPtr create(Domain* domain, string_view name);
protected:
explicit ExampleNode2D(Domain* domain, string_view name);
void onExampleMessage(ExampleMessageArguments& arguments);
private:
ClassPropertyDefaultValue<float> m_classValueExampleProperty;
};
The next sections explain different parts of the node declaration.
Metaclass
Each class derived from Node2D must have a metaclass definition. To declare the metaclass, inherit from the Node2D base class and list the properties specific to the inherited node:
For details about metaclass, see the description in Node documentation.
Property types
Local property types are declared in metaclass to belong to the node. Additionally, property types must be declared within the node:
static PropertyType<float> ExampleProperty;
It is also often useful to declare setters and getters to wrap getProperty() and setProperty() for the custom property.
float getExampleProperty() const
{
}
void setExampleProperty(float value)
{
}
After declaring a property type in the class, you must add the property definition. The definition lists property metadata. The example property is defined as follows:
(
metadata.displayName = "Example property";
metadata.tooltip = "Property used as example.";
metadata.host = "Node:user, Node2D:context, Material:user";
metadata.lowerBound = "0.0";
metadata.upperBound = "1.0";
metadata.step = "0.01";
));
Note that the property has the PropertyTypeChangeFlagFinalTransformation flag set. This means that updateRender must be called for the node when the property value changes.
These property change flags determine what Kanzi has to recalculate when the property value changes.
Nodes can have class values for properties:
ClassPropertyDefaultValue<float> m_classValueExampleProperty;
A class value overrides the default value that the node otherwise has for a property, but the value applies only to objects of a certain class.
For more information about properties in nodes, see the documentation of the Node class.
Message types
To communicate with each other, Kanzi nodes send messages.
Declare the message types in the node:
class ExampleMessageArguments : public MessageArguments
{
public:
static PropertyType<bool> ExampleArgumentProperty;
};
static MessageType<ExampleMessageArguments> ExampleMessage;
Like the node itself, the message class must define a metaclass and properties.
You must also define the message type, metadata, and related property metadata:
PropertyType<bool> ExampleNode2D::ExampleMessageArguments::ExampleArgumentProperty(
kzMakeFixedString(
"MessageArgument.ExampleNode2D.Example"),
false, 0,
false,
(
metadata.displayName = "Example argument";
metadata.tooltip = "Example message argument property";
));
{
metadata.displayName = "Example message";
metadata.tooltip = "Example definition of a message that can be listened.";
));
}
MessageType<ExampleNode2D::ExampleMessageArguments> ExampleNode2D::ExampleMessage(
kzMakeFixedString(
"Message.ExampleNode2D.Example"),
nullptr);
The argument definition is similar to property type definition. You also need to define the message type and metadata for Kanzi Studio.
A node can subscribe to listen to any messages. Typically this happens on initialization.
For more information about messages, see the documentation of the Node class.
Initialize pattern
Constructing a node initializes node-specific values and passes them to the base class constructor.
ExampleNode2D::ExampleNode2D(Domain* domain, string_view name) :
Node2D(domain, name),
m_classValueExampleProperty(*this, ExampleProperty, 0.5f)
{
}
Class values are initialized in the constructor.
Further initialization is done in Node::initialize(), that is called from the create function:
ExampleNode2DSharedPtr ExampleNode2D::create(Domain* domain, string_view name)
{
ExampleNode2DSharedPtr exampleNode(new ExampleNode2D(domain, name));
exampleNode->initialize();
return exampleNode;
}
In this example, the node subscribes to listen a message defined earlier upon initialize:
void ExampleNode2D::initialize()
{
addMessageHandler(ExampleMessage, bind(&ExampleNode2D::onExampleMessage,
this, placeholders::_1));
}
void ExampleNode2D::onExampleMessage(ExampleMessageArguments& arguments)
{
bool exampleArgument = arguments.getArgument(ExampleMessageArguments::ExampleArgumentProperty);
setExampleProperty(exampleArgument ? 1.0f : 0.0f);
}
For details of initialization, see the documentation of the Node class.
Attach and detach
When a node becomes a part of the node tree, it is attached. When a node is no longer a part of the node tree, it is detached. Nodes can also be attached or detached if their parent is attached or detached. This typically happens when the parent is added or removed from the node tree.
Attaching connects and activates node features related to its location in the node tree. This includes resource references, bindings, triggers, input manipulators, and so on.
For details on attach and detach, see the documentation of the Node class.
Rendering
Custom node rendering is controlled by overriding rendering functions and setting the render type. During the render process, nodes first call their rendering functions, then rendering descends to the children.
Rendering functions
To override the rendering of the foreground, implement renderForegroundOverride(). The default implementation of renderForegroundOverride() is empty, because all nodes decide on their own rendering.
To override the rendering of both the foreground and background, implement renderSelfOverride(). The default implementation of renderSelfOverride() applies the composition stack, and then defers to background and foreground rendering. When implementing this function, remember to ensure that the viewport settings are correct before you issue draw calls.
To use normal background rendering within overridden rendering, call renderBackground(). renderBackground() checks whether a background brush exists, and then renders the background quad. In the case of opaque foreground, background rendering renders a 'frame' around the node content area, if possible.
When you want to override the entire rendering process of a 2D node, implement renderOverride(). This can be necessary in some rare cases. For example, implement renderOverride() when you want to alter the way caching or the allocation of composition targets works.
For most nodes, implementing renderSelfOverride() is enough.
Render type
Node2D rendering is controlled by RenderType. Set it upon constructor or node initialization to reflect on node rendering behavior. RenderType acts as a hint to the rendering system, regarding how to set viewport settings and how to handle background rendering.
Layout
A custom node follows the layout directives described in the Basic layout section. You can override the layout partially by implementing layout functions.
Measurement pass
In measure(), Kanzi determines the desired size of a node.
The measurement pass descends recursively downwards until it finds nodes that are flagged as needing measure. For every node whose size changed, measure ascends upwards to the root and flags the node as requiring arrange.
To override the size that Kanzi otherwise determines for the node, implement measureOverride():
Vector2 ExampleNode2D::measureOverride(Vector2 )
{
return Vector2(128.0f, 128.0f);
}
The size returned by measureOverride() determines the desired size of the content. The desired size of the node is affected by the desired size of the content and the properties of the node.
Arrange pass
In arrange(), Kanzi determines the actual size and transformation of the node.
The arrange pass descends recursively downwards to nodes that are flagged as needing arrange, and then arranges those nodes and their children.
The arrange process:
- Reads the available size for the node.
- Determines the transformation and actual size of the node based on the properties of the node.
Nodes that perform layout on their child nodes must implement arrangeOverride(). During the arrange pass of the parent node, Kanzi already finished measuring the children nodes. Arranging children works by iterating over child nodes and setting their allocated sizes and arrange transformations. For non-layout nodes, (default) arrangeOverride() sets the allocated size of the child nodes as the actual size of the node, and resets child arrange transformation.
Update render pass
In updateRender(), Kanzi determines the final transformation, brushes, and composition settings of a node.
Kanzi calls updateRender() after arrange for all nodes that are marked as requiring a transformation update.
A node can implement updateRenderOverride() to do custom clipping or modify brush or composition settings:
void ExampleNode2D::updateRenderOverride()
{
if (brush)
{
ColorRGBA color = brush->getColor();
color.setBlue(getExampleProperty());
brush->setColor(color);
}
}